﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Lm.Common.ExtensionMethods;

namespace Lm.Common.Auth.Client.ClientRoot
{
    class LoginInfo
    {
        protected string Account { get; set; }
        protected DateTime? LoginTime { get; set; }
        protected string Token { get; set; }

        public void Set(string account, DateTime loginTime, string token)
        {
            this.Account = account;
            this.LoginTime = loginTime;
            this.Token = token;
            Root.ClientRoot.MainForm.SetLoginStatus("当前用户:" + this.Account + "  登录时间:" + this.LoginTime.ToString());
        }

        public string GetToken()
        { return this.Token; }

        public void ClearLoginInfo()
        {
            this.Account = null;
            this.LoginTime = null;
            this.Token = null;
            Root.ClientRoot.MainForm.SetLoginStatus("未登录");
        }

        public bool IsLogin
        {
            get
            {
                if (this.Token.IsNullOrBlank())
                { return false; }
                else
                { return true; }
            }
        }
    }
}
